package com.gm.service;

import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.gm.bean.Player;

public class GetJsonArray {

	public String getJsonArray(List<Player> players) throws JSONException{
		JSONArray jsonarray = new JSONArray();
		for(Player p :players){
			JSONObject json = new JSONObject();
			json.put("number",p.getNumber());
			json.put("name",p.getName());
			json.put("position",p.getPosition());
			json.put("height",p.getHight());
			jsonarray.put(json);
		}
		return jsonarray.toString();
	}
}
